//==============================================================================
#include "CApp.h"

//==============================================================================
bool CApp::OnInit() {
    if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
        return false;
    }

    if((Surf_Display = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF)) == NULL) {
        return false;
    }

//	if((Surf_Test = CSurface::OnLoad("myimage.bmp")) == NULL) {
//		return false;
//	}

    PropertyAddress rootAddress;
    LinuxRemoteProperty eve(&rootAddress, &mPropertyPacket);
    mLeft = (LinuxRemoteProperty*)eve.getChild(1);
    mRight = (LinuxRemoteProperty*)eve.getChild(2);

	// set manual to true
    *((LinuxRemoteProperty*)mLeft->getChild(2)) = true;
    *((LinuxRemoteProperty*)mRight->getChild(2)) = true;

    mLeftTarget = (LinuxRemoteProperty*)mLeft->getChild(0);
    mRightTarget = (LinuxRemoteProperty*)mRight->getChild(0);

    LinuxRemoteProperty *servo = (LinuxRemoteProperty*)eve.getChild(3);
    mServoEnabled = (LinuxRemoteProperty*)servo->getChild(0);
    mServoPosition = (LinuxRemoteProperty*)servo->getChild(1);

    *mServoEnabled = true;
    mServoPositionCached = *mServoPosition;

    SDL_WM_GrabInput(SDL_GRAB_ON);

    return true;
}

//==============================================================================
